/*
 * @Description: 定义路由
 * @Date: 2021-03-08 17:21:22
 * @Author: 黄治恩
 */

import Layout from '@/layouts'
import Home from '@/views/Home'
import User from '@/views/User'
import About from '@/views/About'
import ArticleDetail from '@/views/Article/detail'

import NotFound from '@/views/Error/404'

// 给路由定义类型接口
export interface RouteOption {
  path:string,
  redirect?: string,
  component?: any,
  privated?: boolean,
  exact?: boolean,
  routes?: RouteOption[]
}

const routes: RouteOption[] = [
  {
    path:'/404',
    component: NotFound,
    exact: true
  },
  // 默认布局的页面
  // 需要放在最后面，其他页面放在前面，不然会优先匹配 '/'
  { 
    path: '/',
    component: Layout,
    routes: [
      {
        path: '/',
        component: Home,
        exact: true
      },
      {
        path: '/user',
        component: User,
        privated: true
      },
      {
        path: '/about',
        component: About,
        privated: true
      },
      {
        path: '/article/:id',
        component: ArticleDetail,
        privated: true
      }
    ]
  }
]

export default routes